import datetime,calendar

class DateTime():
    def __init__(self):
        # 本地时间
        self.now = datetime.datetime.now()

    def get_date(self):
        #获取日期
        now_date = self.now.date()
        #格式化日期
        formatted_now_date = now_date.strftime("%Y-%m-%d")
        return formatted_now_date

    def get_time(self):
        #获取时间
        now_time = self.now.time()   #17:25:42.556009
        #格式化时间
        formatted_now_time = now_time.strftime("%H:%M:%S")  #17:26:16
        return formatted_now_time

    def get_week(self):
        date = datetime.datetime.strptime(self.get_date(),"%Y-%m-%d")
        weekday_number = calendar.weekday(date.year,date.month,date.day)
        return ["星期一","星期二","星期三","星期四","星期五","星期六","星期日"][weekday_number]


# if __name__ == '__main__':
#     d = DateTime()
#     date = d.get_date()
#     print(date)
#     time = d.get_time()
#     print(time)
#     week = d.get_week()
#     print(week)


